--SOUNDS :
-- NORMAL : ??
local getInitialName = function(mobName)
	local isShowed = minetest.settings:get_bool("simpleanimals.initial_nametags")
	if isShowed then
		return mobName
	end
end

mobs:register_mob("frog:frog", {
	nametag = getInitialName("FROG"),
	type = "animal",
	passive = false,
	attack_type = "dogfight",
	attack_animals = true,
	specific_attack = { "mobs_animal:bee" },
	pathfinding = true,
	reach = 2,
	damage = 5,
	hp_min = 5,
	hp_max = 5,
	armor = 150,
	collisionbox = {-0.3, -1.0, -0.2, 0.2, 0.05, 0.2},
	visual = "mesh",
	mesh = "frog.b3d",
	rotate = 180,
	textures = {
		{"frog.png"},
		--{"frog_brown.png"}, --colored in on_spawn
		--{"frog_red.png"}, --colored in on_spawn
	},
	--blood_texture = "",
	makes_footstep_sound = true,
	sounds = {
		--attack = "",
		random = "frog",
		--death = "",
	},
	walk_velocity = 2,
	run_velocity = 3,
	jump = true,
	jump_height = 3.1, --hight jump
	fly_in = {"default:water_source", "default:water_flowing"},
	floats = 2, --nothing in the water.
	stepheight = 1.1, 
	--fall_damage = 1, --without damage in fall
	view_range = 5, --less see distance
	drops = {
		--{name = "skulls:bone", chance = 2, min = 1, max = 1},
		{name = "mobs_animal:bee", chance = 20, min = 0, max = 1}, --drop bee just death
	},
	water_damage = 0,
	lava_damage = 5,
	light_damage = 0,
	follow = {"mobs_animal:bee"}, 
	animation = {
		speed_normal = 15,
		stand_start = 0,
		stand_end = 15,
		walk_start = 20,
		walk_end = 100,
		fly_start = 20, 
		fly_end = 100,
		--run_start = 50,
		--run_end = 59,
		punch_start = 120,
		punch_end = 140,
		punch_speed = 30,
	},
	on_rightclick = function(self, clicker) -- No momento pode somente , repodruzir ou Curar...
		if mobs:feed_tame(self, clicker, 8, true, true) then
			return 
		end
		
		if mobs:protect(self, clicker) then return end
		if mobs:capture_mob(self, clicker, 30, 50, 80, false, nil) then return end
	end,
	on_spawn = function(self)
		local frog_types = {
			{--Spawn in Nether
				nodes = {
					"nether:rack",
					"nether:rack_deep",
				},
				skins = {"frog_red.png"},
			},
			{--Spawn in Rain Firest
				nodes = {"default:dirt_with_rainforest_litter"},
				skins = {"frog_brown.png"},
			},
		}
		local pos = self.object:get_pos() ; pos.y = pos.y - 1
		local tmp
		for n = 1, #frog_types do
			tmp = frog_types[n]
			if minetest.find_node_near(pos, 1, tmp.nodes) then
				self.base_texture = tmp.skins
				self.object:set_properties({textures = tmp.skins})
				if tmp.drops then
					self.drops = tmp.drops
				end
				return true
			end
		end

		return true -- run only once, false/nil runs every activation
	end,
})

mobs:spawn({
	name = "frog:frog",
	nodes = {
		"default:dirt_with_grass", "default:dirt", "default:water_source", "default:water_flowing",--green frog
		"default:dirt_with_rainforest_litter", --brown frog
		"nether:rack", "nether:rack_deep", --red frog
	},
	--[[  
	neighbors = {--in surface of water, bat not in deep ocean. (Not is mandatiry exist water near.)
		"air", 
		"default:water_source", "default:water_flowing",
	},
	--]]
	min_light = 0,
	max_light = 10,
	chance = 8000,
	min_height = -10,
	max_height = 200,
	--day_toggle = true,
})

mobs:register_egg("frog:frog", "Frog", "frogegg.png", 1)



